<template>
	<view class="box">

		<view class="" style="position: relative;">
			<image src="https://web.78keji.cn/images/ysh/bg1.png" mode="widthFix" style="width:100%;"></image>
			<view class="tx d_f j_c_c a_i_c" @click="tx" v-if="look==1">
				提现
			</view>
		</view>


		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color='#F02B21'></u-tabs>
		<view class="" v-if="flag==1">
			<view class="" style="height: 20rpx;">

			</view>
			<view class="boss" style="margin-top: 54rpx;" v-if="current==0">

				<view class="d_f a_i_c j_c_c"
					style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
					今日转化

				</view>
				<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

				</view>
				<view class="d_f a_i_c j_c_c"
					style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
					{{data.zh_num}}
				</view>
				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;"
						v-if="data.zh_num_compare_yesterday>0">
						<text style="color: grey;">较昨日</text> <text
							style="color: #EC3314;">+{{data.zh_num_compare_yesterday}}</text>
					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;" v-else>
						<text style="color: grey;">较昨日</text> <text
							style="color: #5C8737;">{{data.zh_num_compare_yesterday}}</text>
					</view>
				</view>

			</view>
			<view class="boss" v-else>
				<view class="d_f a_i_c j_c_c"
					style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
					总uv

				</view>
				<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

				</view>
				<view class="d_f a_i_c j_c_c"
					style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
					{{data.num}}
				</view>


			</view>
			<view class="boss" style="margin-top: 54rpx;">

				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
						今日解约

					</view>
					<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
						{{data.today_cancel_order_number}}
					</view>


				</view>
				<view class="" v-else>
					<view class="d_f a_i_c j_c_c"
						style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
						总转化

					</view>
					<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
						{{data.zh_num}}
					</view>



				</view>
			</view>
			<view class="boss" style="margin-top: 54rpx;">
				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
						今日有效订单

					</view>
					<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
						{{data.zh_num-data.today_cancel_order_number}}
					</view>
				</view>
				<view class="" v-else>
					<view class="d_f a_i_c j_c_c"
						style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
						总转化率

					</view>
					<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
						{{data.zh_num_percentage}}%
					</view>
				</view>


			</view>
		</view>
		<view class="" v-if="flag==2">
			<view class="" style="height: 20rpx;">

			</view>
			<view class="boss">
				<view class="d_f a_i_c j_c_c"
					style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
					总UV

				</view>
				<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

				</view>
				<view class="d_f a_i_c j_c_c"
					style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
					{{data.num}}
				</view>

				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;"
						v-if="data.num_compare_yesterday>0">
						<text style="color: grey;">较昨日</text> <text
							style="color: #EC3314;">+{{data.num_compare_yesterday}}</text>
					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;" v-else>
						<text style="color: grey;">较昨日</text><text
							style="color: #5C8737;">{{data.num_compare_yesterday}}</text>
					</view>
				</view>
			</view>
			<view class="boss" style="margin-top: 54rpx;">

				<view class="d_f a_i_c j_c_c"
					style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
					总转化

				</view>
				<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

				</view>
				<view class="d_f a_i_c j_c_c"
					style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
					{{data.zh_num}}
				</view>
				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;"
						v-if="data.zh_num_compare_yesterday>0">
						<text style="color: grey;">较昨日</text> <text
							style="color: #EC3314;">+{{data.zh_num_compare_yesterday}}</text>
					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;" v-else>
						<text style="color: grey;">较昨日</text> <text
							style="color: #5C8737;">{{data.zh_num_compare_yesterday}}</text>
					</view>
				</view>

			</view>
			<view class="boss" style="margin-top: 54rpx;">
				<view class="d_f a_i_c j_c_c"
					style="padding-top: 26rpx;font-weight: bold;font-size: 36rpx;position: relative;">
					总转化率

				</view>
				<view class="" style="width: 672rpx;;margin-top: 16rpx;border-top: 1px solid #C7C6C6;">

				</view>
				<view class="d_f a_i_c j_c_c"
					style="font-weight: bold;font-size: 40rpx;color: #000000;padding-top: 41rpx;">
					{{data.zh_num_percentage}}%
				</view>

				<view class="" v-if="current==0">
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;"
						v-if="data.zh_num_percentage_compare_yesterday>0">
						<text style="color: grey;">较昨日</text> <text
							style="color: #EC3314;">+{{data.zh_num_percentage_compare_yesterday}}%</text>
					</view>
					<view class="d_f a_i_c j_c_c"
						style="font-weight: bold;font-size: 30rpx;color: #000000;padding-top: 40rpx;" v-else>
						<text style="color: grey;">较昨日</text> <text
							style="color: #5C8737;">{{data.zh_num_percentage_compare_yesterday}}%</text>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	import {
		sendSms,
		checkSms,
		ljjList,
		wxLogins,
		ljjLq,
		getProType,
		openSignDecrypt,
		ljjStatusEdit,
		jyqList,
		jyqStatusEdit,
		getAliUser,
		decodeQrcode
	} from '../../api/index.js'
	import moment from '../../utils/moment.js'
	import md5 from '../../utils/md5.js'
	export default {
		data() {
			return {
				text: '+20',
				look: '',
				list: [{
					name: '今日数据'
				}, {
					name: '本月数据'
				}, {
					name: '历史数据',

				}],
				current: 0,
				flag: '',

				data: {
					num: 0, //总uv
					num_compare_yesterday: 0, //总uv，较昨日
					zh_num: 0, //总转化
					zh_num_compare_yesterday: 0, //总转化，较昨日
					zh_num_percentage: 0, //转化率
					zh_num_percentage_compare_yesterday: 0 //转化率，较昨日
				}
			}
		},
		components: {

		},
		methods: {
			change(index) {
				this.current = index;
				this.getdata()
			},
			tx() {
				uni.navigateTo({
					url: '/pages/tx/tx'
				})
			},
			getdata() {
				uni.showLoading({
					title: '获取数据，请稍等',
					mask: true
				});
				uni.request({
					url: 'https://tcapi.sx2b2c.com/api/client_api/getStatistics', // 你的API地址
					method: 'POST',
					data: {
						type: this.current + 1,
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded', // 默认值
						token: uni.getStorageSync('token'),
					},
					success: (res) => {
						console.log('POST请求成功', res.data.data);
						this.data = res.data.data

						uni.hideLoading()
						if (this.data.qdid>6555&&this.data.qdid<6966) {
							this.flag = 1
						} else {
							this.flag = 2
						}
						console.log(this.flag)
					},
					fail: (err) => {
						console.error('POST请求失败', err);
						uni.hideLoading()
					}
				});
			}

		},
		onLoad(option) {
			this.look = option.look

			this.getdata()

		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped lang='scss'>
	.boss {
		width: 668rpx;

		background: #FEFEFE;
		box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(255, 216, 191, 0.63);
		border-radius: 22rpx;

		margin: 0 auto;
		padding-bottom: 35rpx;
	}

	.tx {
		background-color: #FC4006;
		width: 141rpx;
		height: 62rpx;
		box-shadow: -1rpx 3rpx 3rpx 0rpx rgba(246, 134, 98, 0.61);
		border-radius: 31rpx;
		color: white;
		position: absolute;
		right: 82rpx;
		top: 150rpx;
		color: #FEFEFE;

	}
</style>